algalcommand.alpha
Class NetworkScanner

java.lang.Object
  extended by algalcommand.alpha.NetworkScanner
All Implemented Interfaces:
java.lang.Runnable

public class NetworkScanner
extends java.lang.Object
implements java.lang.Runnable


Nested Class Summary
 class NetworkScanner.LantronixDevice
          parsing based on the following c code from Lantronix tech support forums:
           len = recvfrom(sock, buf, sizeof(buf), 0, (struct sockaddr *)&from, &fromLen);            if (len > 4) {                                if (buf[3] != 0xf7) {                    printf("buf[3]=%x\n", buf[3]);                    continue;                }                                printf("Type    : %02x-%02x (%c%c)\n", buf[8], buf[9], buf[8], buf[9] );                printf("Version : Major.Minor: %d.%d\n", buf[7], buf[6] );                printf("Serial #: %02x-%02x-%02x-%02x\n", buf[20], buf[20+1], buf[20+2],                        buf[20+3]);                printf("MAC     : %02x-%02x-%02x-%02x-%02x-%02x\n", buf[24], buf[24+1],                        buf[24+2], buf[24+3], buf[24+4], buf[24+5]);                printf("IP Addr : %s\n", inet_ntoa(from.sin_addr));            } else {                printf("erroneous data.\n");            }            printf("\n");
 
Field Summary
static byte[] LANTRONIX_DISCOVERY_COMMAND
           
static int LANTRONIX_DISCOVERY_PORT
           
static byte LANTRONIX_DISCOVERY_RESPONCE_CODE
           
 
Constructor Summary
NetworkScanner(java.lang.String subnetaddress)
           
NetworkScanner(java.lang.String subnetaddress, int timeout_seconds)
           
 
Method Summary
 NetworkScanner.LantronixDevice[] findOrphanedDevices(java.lang.String broadcast_address, int timeout)
           
 Photobioreactor[] getPBRs()
           
static void main(java.lang.String[] args)
           
 void run()
          This is the thread that detects the photobioreactors on the network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LANTRONIX_DISCOVERY_PORT

public static final int LANTRONIX_DISCOVERY_PORT
See Also:
Constant Field Values

LANTRONIX_DISCOVERY_COMMAND

public static final byte[] LANTRONIX_DISCOVERY_COMMAND

LANTRONIX_DISCOVERY_RESPONCE_CODE

public static final byte LANTRONIX_DISCOVERY_RESPONCE_CODE
See Also:
Constant Field Values
Constructor Detail

NetworkScanner

public NetworkScanner(java.lang.String subnetaddress)

NetworkScanner

public NetworkScanner(java.lang.String subnetaddress,
                      int timeout_seconds)
Method Detail

getPBRs

public Photobioreactor[] getPBRs()
Returns:
All of the Photobioreactors that have been found on the network. This method should not be invoked until after running this object in a thread. Example:
NetworkScanner scanner = new NetworkScanner("192.168.0.*");
Thread t = new Thread(scanner);
t.start(); // causes the NetworkScanner to scan the network for PBRs
t.join();// wait until scanner is done searching the network
pbrarray = scanner.getPBRs();

findOrphanedDevices

public NetworkScanner.LantronixDevice[] findOrphanedDevices(java.lang.String broadcast_address,
                                                            int timeout)
Returns:
Array of IP addresses to PBRs that respond to the network discovery datagram (and therefore are not connected)

run

public void run()
This is the thread that detects the photobioreactors on the network. After this thread finishes, the

Specified by:
run in interface java.lang.Runnable

main

public static void main(java.lang.String[] args)
Parameters:
args - the command line arguments